package com.yanqu.road.entity.activity.sonhai.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.activity.sonhai.enums.SonHaiRewardFlagEnum;
import com.yanqu.road.entity.activity.sonhai.enums.SonHaiWinFlagEnum;

import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_c_activity_son_hai_plot_data")
public class SonHaiPlotData extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "分组ID", select = true, update = true)
    private int groupId;

    @FieldTypeAnnotation(desc = "队伍ID")
    private int teamId;

    @FieldTypeAnnotation(desc = "玩家ID")
    private long userId;

    @FieldTypeAnnotation(desc = "区域唯一ID")
    private int regionUniqueId;

    @FieldTypeAnnotation(desc = "区域ID")
    private int regionId;

    @FieldTypeAnnotation(desc = "x坐标")
    private int x;

    @FieldTypeAnnotation(desc = "y坐标")
    private int y;

    @FieldTypeAnnotation(desc = "地块事件配置ID,")
    private int plotId;

    @FieldTypeAnnotation(desc = "地块类型")
    private int type;

    @FieldTypeAnnotation(desc = "地块等级")
    private int level;

    @FieldTypeAnnotation(desc = "是否镇伏，0：未镇伏，1：已镇伏")
    private int winFlag;

    @FieldTypeAnnotation(desc = "镇伏时间")
    private long winTime;

    @FieldTypeAnnotation(desc = "奖励是否领取，0：未领取，1：已领取")
    private int getRewardFlag;

    @FieldTypeAnnotation(desc = "奖励")
    private String reward;

    @FieldTypeAnnotation(desc = "额外增加的山海灵气")
    private long extraAuraScore;

    @FieldTypeAnnotation(desc = "异兽数据")
    private SonHaiBeastData beastData;

    @FieldTypeAnnotation(desc = "PVP玩家ID")
    private long pvpUserId;

    @FieldTypeAnnotation(desc = "蛋id")
    private int eggId;

    @FieldTypeAnnotation(desc = "是否删除")
    private int delFlag;

    @FieldTypeAnnotation(desc = "攻击地块次数")
    private Map<Long, Integer> attNumMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "二选一事件奖励是否选择过，0：未选择，1：已选择")
    private int chooseRewardFlag;

    @FieldTypeAnnotation(desc = "创建时间")
    private long createTime;

    public SonHaiPlotData() {
    }

    public SonHaiPlotData(int activityId, int groupId, int teamId, long userId, int regionUniqueId, int regionId, int x, int y, int plotId, int type, int level) {
        this.activityId = activityId;
        this.groupId = groupId;
        this.regionUniqueId = regionUniqueId;
        this.teamId = teamId;
        this.userId = userId;
        this.regionId = regionId;
        this.x = x;
        this.y = y;
        this.plotId = plotId;
        this.type = type;
        this.level = level;
        this.winFlag = SonHaiWinFlagEnum.WIN_NOT.getType();
        this.winTime = 0;
        this.getRewardFlag = SonHaiRewardFlagEnum.GET_NOT.getType();
        this.reward = "";
        this.extraAuraScore = 0;
        this.pvpUserId = 0;
        this.eggId = 0;
        this.delFlag = 0;
        this.chooseRewardFlag = SonHaiRewardFlagEnum.GET_NOT.getType();
        this.createTime = System.currentTimeMillis();
        setInsertOption();
    }

    public int getActivityId() {
        return activityId;
    }
    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        if (this.groupId != groupId) {
            this.groupId = groupId;
            setOp(DataStatus.Update);
        }
    }

    public int getTeamId() {
        return teamId;
    }
    public void setTeamId(int teamId) {
        if (this.teamId != teamId) {
            this.teamId = teamId;
            setOp(DataStatus.Update);
        }
    }

    public long getUserId() {
        return userId;
    }
    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public int getRegionUniqueId() {
        return regionUniqueId;
    }
    public void setRegionUniqueId(int regionUniqueId) {
        if (this.regionUniqueId != regionUniqueId) {
            this.regionUniqueId = regionUniqueId;
            setOp(DataStatus.Update);
        }
    }

    public int getRegionId() {
        return regionId;
    }
    public void setRegionId(int regionId) {
        if (this.regionId != regionId) {
            this.regionId = regionId;
            setOp(DataStatus.Update);
        }
    }

    public int getX() {
        return x;
    }
    public void setX(int x) {
        if (this.x != x) {
            this.x = x;
            setOp(DataStatus.Update);
        }
    }

    public int getY() {
        return y;
    }
    public void setY(int y) {
        if (this.y != y) {
            this.y = y;
            setOp(DataStatus.Update);
        }
    }

    public int getPlotId() {
        return plotId;
    }

    public void setPlotId(int plotId) {
        if (this.plotId != plotId) {
            this.plotId = plotId;
            setOp(DataStatus.Update);
        }
    }

    public int getType() {
        return type;
    }
    public void setType(int type) {
        if (this.type != type) {
            this.type = type;
            setOp(DataStatus.Update);
        }
    }

    public int getLevel() {
        return level;
    }
    public void setLevel(int level) {
        if (this.level != level) {
            this.level = level;
            setOp(DataStatus.Update);
        }
    }

    public int getWinFlag() {
        return winFlag;
    }
    public void setWinFlag(int winFlag) {
        if (this.winFlag != winFlag) {
            this.winFlag = winFlag;
            setOp(DataStatus.Update);
        }
    }

    public int getGetRewardFlag() {
        return getRewardFlag;
    }
    public void setGetRewardFlag(int getRewardFlag) {
        if (this.getRewardFlag != getRewardFlag) {
            this.getRewardFlag = getRewardFlag;
            setOp(DataStatus.Update);
        }
    }

    public String getReward() {
        return reward;
    }

    public void setReward(String reward) {
        if (!Objects.equals(this.reward, reward)) {
            this.reward = reward;
            setOp(DataStatus.Update);
        }
    }

    public long getExtraAuraScore() {
        return extraAuraScore;
    }

    public void setExtraAuraScore(long extraAuraScore) {
        if (this.extraAuraScore != extraAuraScore) {
            this.extraAuraScore = extraAuraScore;
            setOp(DataStatus.Update);
        }
    }

    public long getWinTime() {
        return winTime;
    }
    public void setWinTime(long winTime) {
        if (this.winTime != winTime) {
            this.winTime = winTime;
            setOp(DataStatus.Update);
        }
    }

    public SonHaiBeastData getBeastData() {
        return beastData;
    }

    public void setBeastData(SonHaiBeastData beastData) {
        if (this.beastData != beastData) {
            this.beastData = beastData;
            setOp(DataStatus.Update);
        }
    }

    public long getPvpUserId() {
        return pvpUserId;
    }
    public void setPvpUserId(long pvpUserId) {
        if (this.pvpUserId != pvpUserId) {
            this.pvpUserId = pvpUserId;
            setOp(DataStatus.Update);
        }
    }

    public int getEggId() {
        return eggId;
    }
    public void setEggId(int eggId) {
        if (this.eggId != eggId) {
            this.eggId = eggId;
            setOp(DataStatus.Update);
        }
    }

    public int getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(int delFlag) {
        if (this.delFlag != delFlag) {
            this.delFlag = delFlag;
            setOp(DataStatus.Update);
        }
    }

    public Map<Long, Integer> getAttNumMap() {
        return attNumMap;
    }

    public int getAttNum(long userId) {
        return attNumMap.getOrDefault(userId, 0);
    }

    public void addAttNum(long userId) {
        if (attNumMap.containsKey(userId)) {
            attNumMap.put(userId, attNumMap.get(userId) + 1);
        } else {
            attNumMap.put(userId, 1);
        }
        setOp(DataStatus.Update);
    }

    public void setAttNumMap(Map<Long, Integer> attNumMap) {
        this.attNumMap = attNumMap;
    }

    public int getChooseRewardFlag() {
        return chooseRewardFlag;
    }

    public void setChooseRewardFlag(int chooseRewardFlag) {
        if (this.chooseRewardFlag != chooseRewardFlag) {
            this.chooseRewardFlag = chooseRewardFlag;
            setOp(DataStatus.Update);
        }
    }

    public long getCreateTime() {
        return createTime;
    }
    public void setCreateTime(long createTime) {
        if (this.createTime != createTime) {
            this.createTime = createTime;
            setOp(DataStatus.Update);
        }
    }
}
